package com.zxcz.controller;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.zxcz.tools.Constants;


/**
 * 控制功能模块跳转
 * @author root
 *
 */
@Controller
public class IndexController {
	
	/**
	 * 用户登录
	 */
	@RequestMapping(value = "/login")
	public String login() {
		return "login";
	}
	
	@RequestMapping(value = "/resourceManage")
	@PreAuthorize("hasRole('" + Constants.ROLE_ADMIN_NAME + "')")
	public String resourceManage() {
		return "index/admin_resource";
	}
	
	@RequestMapping(value = "/firmwareManage")
	@PreAuthorize("hasRole('" + Constants.ROLE_ADMIN_NAME + "')")
	public String firmwareManage() {
		return "index/admin_index";
	}
	
	/**
	 * 跳转内容商页
	 * @return
	 */
	@RequestMapping(value = "/userManage")
	@PreAuthorize("hasRole('" + Constants.ROLE_ADMIN_NAME + "')")
	public String userManage() {
		return "index/user";
	}
	
	/**
	 * 跳转设备页
	 * @return
	 */
	@RequestMapping(value = "/devicesManage")
	@PreAuthorize("hasRole('" + Constants.ROLE_ADMIN_NAME + "')")
	public String devicesManage() {
		return "index/devices";
	}
	
	@RequestMapping(value = "/userResourceManage")
	@PreAuthorize("hasRole('" + Constants.ROLE_USER_NAME + "')")
	public String userResourceManage() {
		return "index/user_index";
	}
	
	/**
	 * 跳转用户设备页
	 * @return
	 */
	@RequestMapping(value = "/userDevicesManage")
	@PreAuthorize("hasRole('" + Constants.ROLE_USER_NAME + "')")
	public String userDevices() {
		return "index/user_device";
	}
}
